package cc.atliberty.creating.eagersingleton;

/**
 * @Author 元宵
 * @url www.atliberty.cc
 * @Date 2023-10-30 17:52
 * @description: 饿汉式单例类测试
 */
public class EagerSingletonTest {
    public static void main(String[] args) {
        // 不能通过new创建对象，会有编译错误
        EagerSingleton eagerSingleton = EagerSingleton.getInstance();
        System.out.println(eagerSingleton);
        EagerSingleton eagerSingleton2 = EagerSingleton.getInstance();
        System.out.println(eagerSingleton == eagerSingleton2);  //true

    }
}
